import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'
// 行车管理
import car from './modules/car'
// 园区管理
import park from './modules/park'
// 物业费管理
import real from './modules/real'
// 一体杆管理
import pole from './modules/pole'
// 系统管理
import system from './modules/system'
Vue.use(Router)

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  // 新增月卡管理
  {
    path: '/cardAdd',
    component: () => import('@/views/car/carTow/add-card.vue')
  },
  {
    path: '/exterpriseDetail',
    component: () => import('@/views/park/parkTow/detatl.vue')
  },
  {
    path: '/add',
    component: () => import('@/views/park/parkTow/add.vue')
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '工作台', icon: 'dashboard' }
    }]
  },
  park,
  car,
  real,
  pole,
  system,

  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
